import React, {Component} from 'react';
import LoginBtn from './user';
import LogoutBtn from './guest'



export default class Login extends Component {
    constructor(props) {
        super(props);
        this.state = {
            isLogin: false
        }
    }

    LoginClick() {
        this.setState({
            isLogin: true
        })
    }

    LogoutClick() {
        this.setState({
            isLogin: false
        })
    }

    render() {
        let button = null;
        let flag = this.state.isLogin;
        if (flag) {
            button = <LogoutBtn onClick={this.LogoutClick.bind(this)} title="Hi 您好！" />;
        } else {
            button = <LoginBtn onClick={this.LoginClick.bind(this)} title="Hi 请登录！"/>;
        }
        return( 
            <div>
                {button}
            </div>
        )
    }
}